﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BL
{
    public class ServiceCheckPointEntrega
    {
        private DalEntity.Implementacao.DalCheckPointEntrega dal;
        public ServiceCheckPointEntrega()
        {
            dal = new DalEntity.Implementacao.DalCheckPointEntrega();
        }
        public bool Gravar(Modelo.CheckPointEntrega chk)
        {
            DalEntity.DalGeral geral = new DalEntity.DalGeral();
            DalEntity.Implementacao.DalCheckpoint chkCheck = new DalEntity.Implementacao.DalCheckpoint();

            try
            { 
                Modelo.CheckPointEntrega chkEntrega = chkCheck.RetornaMaxCheckpointPorEntrega(chk.IdEntrega);
                chk.IdCheckpoint = chkCheck.RetornaProximoCheckPoin(chkEntrega.IdCheckpoint);
                dal.Gravar(chk);
                return true ;
            }
            catch(Exception ex)     {
                Log.insertLog(ex.Message, " Gravar ", "ServiceCheckPointEntrega" );
                throw ex;
           
            }       
                
            
        }




    }
}
